/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2014 All Rights Reserved.
 */
package com.h2o3.carmack.message.json;

import com.alibaba.fastjson.JSONObject;
import com.h2o3.carmack.message.Message;
import com.h2o3.carmack.message.MessageFactory;

/**
 * @author chensheng
 * @version $Id: JsonMessageFactory.java, v 0.1 1/22/14 10:31 PM chensheng Exp $
 */
public class JsonMessageFactory implements MessageFactory {
    @Override
    public <T> Message createMessage(String code, T body) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", code);
        jsonObject.put("body", body);

        return new JsonMessage(jsonObject);
    }
}
